package com.im.event;

import android.text.TextUtils;

import com.core.sdk.core.BaseEvent;
import com.core.sdk.core.Location;
import com.im.model.XmppMessage;
import com.im.util.XmppUtil;

public class FileResultSendEvent extends BaseEvent{

	private static final long serialVersionUID = 1L;
	
	public enum SendStatus{
		sending,finished,failed
	}
	private FileType fileType;
	private String filePath;
	String toUserJid;
	SendStatus sendStatus;
	String desc = null;
	final XmppMessage xmppMessage;
	
	/**
	 * 发送状态
	 */
	public FileResultSendEvent(Location to,FileType fType,String path,String toUserJID,SendStatus status,String description,String fromUser) {
		super(to);
		this.fileType = fType;
		this.filePath = path;
		this.toUserJid = toUserJID;
		this.sendStatus = status;
		this.desc = description == null ? "" : description;
		int msgType =XmppMessage.MSG_TYPE_OTHER ;
		if(fType == FileType.img){
			msgType = XmppMessage.MSG_TYPE_IMG;
		}else if(fType == FileType.audio){
			msgType = XmppMessage.MSG_TYPE_AUDIO;
		}
		String toUser = XmppUtil.getUserNameByUserJID(toUserJID);
		xmppMessage = new XmppMessage(filePath, fromUser, toUser, true, msgType);
		if(!TextUtils.isEmpty(desc.trim())){
			xmppMessage.setDesc(desc.trim());	
		}
	}

	public FileType getFileType() {
		return fileType;
	}

	public void setFileType(FileType fileType) {
		this.fileType = fileType;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	public String getToUserJid() {
		return toUserJid;
	}

	public void setToUserJid(String toUserJid) {
		this.toUserJid = toUserJid;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public XmppMessage getXmppMessage() {
		return xmppMessage;
	}
}
